﻿using System.Collections.Generic;
using DimOS.H;
using DimOS.Internals;
using DimOS.Plugs;

namespace DimOS.Modules
{
    public static class InputProcessor
    {
        public static List<Token> Tokenize(string input)
        {
            var list = List.GroupByStartPosition(Token.Find(input));
            var result = new List<Token>(); Token temp = null;

            for (int i = 0; i < list.Count; i++)
            {   var group = list[i]; //Select the best match in group
                List.SortByPriority(ref group, 0, group.Count - 1);
                if (temp == null || group[0].StartPosition >= temp
                .EndPosition) { temp = group[0]; result.Add(temp); }
            } return result;
        }


        public static void Colorize(ref List<CharColor> left, ref List<CharColor> center, ref List<CharColor> right)
        { }

        public static void Execute(string command)
        { var errors = new List<Error>(); try { Engine.Process
          (command, ref errors); } catch { } errors.Clear(); }
    }
}
